package com.sailing.controller;

import com.sailing.bo.WiselyResponse;
import com.sailing.comm.ActionResult;
import com.sailing.config.ActionCodeConfig;
import com.sailing.service.PushService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 推送服务接口
 *
 * @author : nanji
 * @create 2017-12-13 11:11
 */


@RestController
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.OPTIONS})
public class PushController {

    public static final Logger LOGGER = LoggerFactory.getLogger(PushController.class);

    @Autowired
    private PushService PushService;

    @RequestMapping(value = "/push",method = RequestMethod.POST)
    @ApiOperation(value = "消息推送",notes = "消息推送")
    public String sendServer( ){

        return "消息推送服务";
    }


    /**
     *消息推送
     * @param wiselyResponse
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/send",method = RequestMethod.POST)
    @ApiOperation(value = "消息推送",notes = "消息推送")
    public ActionResult sendServer( @RequestBody WiselyResponse wiselyResponse)throws Exception{

        return new ActionResult(ActionCodeConfig.getSucceedCode(),
                                 ActionCodeConfig.getSucceedMsg(),
                                  PushService.sendMessage(wiselyResponse),
                                null);
    }



}
